From: Mark Jonas <mark.jonas@de.bosch.com>
To: Wolfgang Grandegger <wg@grandegger.com>,
Marc Kleine-Budde <mkl@pengutronix.de>
Cc: <linux-can@vger.kernel.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <hs@denx.de>,
<yi.zhu5@cn.bosch.com>, Mark Jonas <mark.jonas@de.bosch.com>
Subject: [PATCH 1/5] can: enable multi-queue for SocketCAN devices
Date: Tue, 5 Jun 2018 20:43:56 +0200 [thread overview]
Message-ID: <1528224240-30786-2-git-send-email-mark.jonas@de.bosch.com> (raw)
In-Reply-To: <1528224240-30786-1-git-send-email-mark.jonas@de.bosch.com>
From: Zhu Yi <yi.zhu5@cn.bosch.com>
The existing SocketCAN implementation provides alloc_candev() to
allocate a CAN device using a single Tx and Rx queue. This can lead to
priority inversion in case the single Tx queue is already full with low
priority messages and a high priority message needs to be sent while the
bus is fully loaded with medium priority messages.
This problem can be solved by using the existing multi-queue support of
the network subsytem. The commit makes it possible to use multi-queue in
the CAN subsystem in the same way it is used in the Ethernet subsystem
by adding an alloc_candev_mqs() call and accompanying macros. With this
support a CAN device can use multi-queue qdisc (e.g. mqprio) to avoid
the aforementioned priority inversion.
The exisiting functionality of alloc_candev() is the same as before.
CAN devices need to have prioritized multiple hardware queues or are
able to abort waiting for arbitration to make sensible use of
multi-queues.
Signed-off-by: Zhu Yi <yi.zhu5@cn.bosch.com>
Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
---
drivers/net/can/dev.c | 8 +++++---
include/linux/can/dev.h | 7 ++++++-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 365a8cc..ac8270c 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -702,7 +702,8 @@ EXPORT_SYMBOL_GPL(alloc_can_err_skb);
/*
* Allocate and setup space for the CAN network device
*/
-struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
+struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max,
+ unsigned int txqs, unsigned int rxqs)
{
struct net_device *dev;
struct can_priv *priv;
@@ -714,7 +715,8 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
else
size = sizeof_priv;
- dev = alloc_netdev(size, "can%d", NET_NAME_UNKNOWN, can_setup);
+ dev = alloc_netdev_mqs(size, "can%d", NET_NAME_UNKNOWN, can_setup,
+ txqs, rxqs);
if (!dev)
return NULL;
@@ -733,7 +735,7 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
return dev;
}
-EXPORT_SYMBOL_GPL(alloc_candev);
+EXPORT_SYMBOL_GPL(alloc_candev_mqs);
/*
* Free space of the CAN network device
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 61f1cf2..07b73d2 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -142,7 +142,12 @@ u8 can_dlc2len(u8 can_dlc);
/* map the sanitized data length to an appropriate data length code */
u8 can_len2dlc(u8 len);
-struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max);
+struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max,
+ unsigned int txqs, unsigned int rxqs);
+#define alloc_candev(sizeof_priv, echo_skb_max) \
+ alloc_candev_mqs(sizeof_priv, echo_skb_max, 1, 1)
+#define alloc_candev_mq(sizeof_priv, echo_skb_max, count) \
+ alloc_candev_mqs(sizeof_priv, echo_skb_max, count, count)
void free_candev(struct net_device *dev);
/* a candev safe wrapper around netdev_priv */
--
2.7.4
next prev parent reply other threads:[~2018-06-05 18:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 18:43 [PATCH 0/5] can: enable multi-queue for SocketCAN devices Mark Jonas
2018-06-05 18:43 ` Mark Jonas [this message]
2018-06-05 18:43 ` [PATCH 2/5] spi: implement companion-spi driver Mark Jonas
2018-06-06 18:47 ` Andy Shevchenko
2018-06-07 14:58 ` AW: " Jonas Mark (BT-FIR/ENG1)
2018-06-08 6:03 ` Oleksij Rempel
2018-06-05 18:43 ` [PATCH 3/5] char: implement companion-char driver Mark Jonas
2018-06-05 18:43 ` [PATCH 4/5] can: implement companion-can driver Mark Jonas
2018-06-05 18:44 ` [PATCH 5/5] spi,can,char: add companion DT binding documentation Mark Jonas
2018-06-06 18:06 ` [PATCH 0/5] can: enable multi-queue for SocketCAN devices Andy Shevchenko
2018-06-07 7:22 ` Oliver Hartkopp
2018-06-13 14:37 ` [PATCH v2 " Mark Jonas
2018-06-13 14:37 ` [PATCH v2 1/5] " Mark Jonas
2018-07-20 14:34 ` Marc Kleine-Budde
2018-06-13 14:37 ` [PATCH v2 2/5] spi: implement companion-spi driver Mark Jonas
2018-06-13 14:37 ` [PATCH v2 3/5] char: implement companion-char driver Mark Jonas
2018-06-13 14:37 ` [PATCH v2 4/5] can: implement companion-can driver Mark Jonas
2018-06-13 14:37 ` [PATCH v2 5/5] spi,can,char: add companion DT binding documentation Mark Jonas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1528224240-30786-2-git-send-email-mark.jonas@de.bosch.com \
--to=mark.jonas@de.bosch.com \
--cc=hs@denx.de \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=wg@grandegger.com \
--cc=yi.zhu5@cn.bosch.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).